package com.linsir.ext.beetl;

import com.linsir.i18n.I18NBuilder;
import org.beetl.core.Context;
import org.beetl.core.Function;
/**
 * @author linsir
 * @title: I18NFun
 * @projectName linsir-mu
 * @description: TODO
 * @date 2021/12/3 22:47
 */
public class I18NFun implements Function{

    @Override
    public Object call(Object[] paras, Context ctx) {
        if (paras.length != 1) {
            throw new RuntimeException("参数错误，请传入一个JSON字符串");
        }
        Object para = paras[0];
        if (para == null) {
            return null;
        }
        String key = para.toString();
        return I18NBuilder.get(key);
    }
}
